#ifndef NETWORK_SERVICE_H
#define NETWORK_SERVICE_H
#include "connection_handler.h"
#include "listener_handler.h"
#include "JService.h"
#include "service_handler.h"
#include <map>

class Listener;
class Service;
class JServiceRunner;
class Connection;
class DatabaseService;
class JMsgProto;
enum NetworkServiceComnand {
	kNetworkServiceComnandSendUserInfo,

};

class NetworkService : public ListenerHandler, public ConnectionHandler, public ServiceHandler
{
public:
	NetworkService(void);
	~NetworkService(void);
public:
	virtual void onAccept(Connection* conncetion);
public:
	virtual void onConnected(Connection* conn);
	virtual void onClose(Connection* conn);
	virtual void onData(Connection*  conn);
	void processClientData(void* data, int len, Connection*  conn);

public:
	virtual void handleCommand(std::string cmd, void* data);
	virtual void handleServiceTimer(int timerId);
public:
	void sendConnectionData(int connId, void* data, int len);

private:
	//std::map<int, Connection*>

	Listener* m_listener;
	Service* m_service;
	JServiceRunner* m_runner;
	DatabaseService* m_dbService;
	std::map<int, Connection*> m_mapConnectin;
	JMsgProto* m_proto;
};
#endif